<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@page import="com.tn.bo.UserProfile" %>
<%@page import="com.tn.bo.Company" %>
<%	
	String userId = (String)request.getSession().getAttribute("loggedInUser");
	Company company = (Company)request.getSession().getAttribute("userCompany");
	UserProfile userProfile = (UserProfile)request.getSession().getAttribute("userProfile"); 
	String companyAdmin = (String)request.getSession().getAttribute("companyAdmin");
	Long userProfileId = userProfile.getUserProfileId();
	
%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">



<head>

<!--  Styles Import -->
<link rel="stylesheet" type="text/css" media="all" href="css/styles.css" />
<script type="text/javascript" src="js/iepngfix_tilebg.js"></script>
<link rel="stylesheet" type="text/css" href="/styles/nesteddatatable.css"/>
<link rel="stylesheet" type="text/css" media="all" href="css/ie.css"/>
<script src="js/html5.js"></script>

<link href="cal/CalendarControl.css" rel="stylesheet" type="text/css" />
<script src="cal/CalendarControl.js" ></script>


<!--  Scripts Import -->
<%@ include file="/jsp/yui_includes.jsp"  %>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type='text/javascript' src='dwr/interface/DWR_PurchaseOrders.js'></script>
<script type='text/javascript' src='dwr/interface/DWR_UserManagement.js'></script>
<script type='text/javascript' src='dwr/interface/DWR_Register.js'></script>
<script type='text/javascript' src='dwr/interface/DWR_Invoice.js'></script>
<script type='text/javascript' src='dwr/interface/DWR_SearchService.js'></script>
<script type="text/javascript" src="../scripts/search.js"></script>
<script type="text/javascript" src="../scripts/localutils.js"></script>
<script type="text/javascript" src="../scripts/podetails.js"></script>
<script type="text/javascript" src="../scripts/pocreate.js"></script>
<script type="text/javascript" src="../scripts/pomain.js"></script>
<script type="text/javascript" src="../scripts/poreceieved.js"></script>
<script type="text/javascript" src="../scripts/posent.js"></script>
<script type="text/javascript" src="../scripts/invreceived.js"></script>
<script type="text/javascript" src="../scripts/invsent.js"></script>
<script type="text/javascript" src="../scripts/pmtreceived.js"></script>
<script type="text/javascript" src="../scripts/pmtsent.js"></script>
<script type="text/javascript" src="../scripts/mainpages.js"></script>
<script type="text/javascript" src="../scripts/yuimenus.js"></script>
<script type="text/javascript" src="../scripts/datatablepatch.js"></script>
<script type="text/javascript" src="../scripts/nestedatatable.js"></script>
<script type="text/javascript" src="../scripts/superusermgmt.js"></script>
<script type="text/javascript" src="../scripts/supplierManagement.js"></script>
<script type="text/javascript" src="../scripts/poinvcreate.js"></script>
<script type="text/javascript" src="../scripts/cmocreate.js"></script>
<script type="text/javascript" src="../scripts/updatepayments.js"></script>
<script type="text/javascript" src="../scripts/cmemoreceived.js"></script>
<script type="text/javascript" src="../scripts/invoiceDetail.js"></script>
<script type="text/javascript" src="../scripts/pmtdetails.js"></script>
<script type="text/javascript" src="../scripts/cmemosent.js"></script>
<script type="text/javascript" src="../scripts/cmemodetails.js"></script>

<script type="text/javascript" src="../scripts/invmain.js"></script>
<script type="text/javascript" src="../scripts/cmmain.js"></script>
<script type="text/javascript" src="../scripts/pymtmain.js"></script>

<!-- Third Party Scripts & Styles-->
<link rel="stylesheet" type="text/css" media="all" href="/thirdpartyscripts/jsdatepick/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="/thirdpartyscripts/jsdatepick/jsDatePick.min.1.3.js"></script>

<link rel="stylesheet" type="text/css" media="all" href="domtab/domtab.css"/>
<script type="text/javascript" src="domtab/domtab.js"></script>
	



<script type="text/javascript" >

document.write('<style type="text/css">');    
document.write('.tabbing_div{display:none;}<');
document.write('/s'+'tyle>');    

var usrcompany_id = null;
var usrcompany_name = null;
var usrname = null;
var usrcompany_uid  = null;
var loggedinuser = "<%=userId%>";
var companyAdmin = "<%=companyAdmin%>"
usrcompany_uid = "<%=company.getCompanyUniqueIdentifier()%>";
usrcompany_id = "<%=company.getCompanyId()%>";
usrcompany_name = "<%=company.getCompanyName()%>";
var usrlname = "<%=userProfile.getLastName()%>";
var usrfname = "<%=userProfile.getFirstName()%>";
var usremail = "<%=userProfile.getEmailAddress()%>";
var usrdelinfo  = "<%=userProfile.getDeliveryInfo()%>";
usrname = usrlname + ", " + usrfname;

function dologout(){
	dwr.util.setValue('lgoutaction','logout');
	dwr.util.setValue('lgoutUser',loggedinuser);
	document.getElementById('logout_form').submit();	
}

//var tabView = new YAHOO.widget.TabView('demo');
var usr_comp_cache = null;
var usr_profile_cache = null;

function setup_usercompcache(handlerfunc){
	var dcmd = {
			callback : handlerfunc,
			exceptionHandler : exception_generic_handler,
			timeout : 100000,
			errorHandler : exception_generic_handler
		};

	DWR_PurchaseOrders.findCompanyById(usrcompany_uid,
			dcmd);
}

function success_getLoggedInUserCompany(dwrresp){
	if (dwrresp && dwrresp.respCode == 0) {
		if (dwrresp.objRespOrError != null) {
			usr_comp_cache = dwrresp.objRespOrError;
		}
	}
}

setup_usercompcache(success_getLoggedInUserCompany);

function setup_userProfileCache(handlerfunc){
	var dcmd = {
			callback : handlerfunc,
			exceptionHandler : exception_generic_handler,
			timeout : 100000,
			errorHandler : exception_generic_handler
		};

	DWR_Register.getUserProfile('<%=userProfileId%>',
			dcmd);
}

function success_getLoggedInUserProfile(dwrresp){
	if (dwrresp && dwrresp.respCode == 0) {
		if (dwrresp.objRespOrError != null) {
			usr_profile_cache = dwrresp.objRespOrError;
			try{
				if(usr_profile_cache != null && usr_profile_cache.currentProperties != null){
						if(! usr_profile_cache.currentProperties.superUser){
							$("manage_comp_profile_li").style.display = "none";
							$("manage_comp_users").style.display = "none";
						} 
							
						 if(!usr_profile_cache.currentProperties.createPO){
							 $("po_create_li").style.display = "none";
						}
	
						 if(!usr_profile_cache.currentProperties.changePO){
							 $("po_change_li").style.display = "none";
						}
	
						 if(!usr_profile_cache.currentProperties.cancelPO){
							 $("po_cancel_li").style.display = "none";
						}
	
						 if(!usr_profile_cache.currentProperties.createInvoices){
							 $("inv_create_li").style.display = "none";
							 $("inv2_create_li").style.display = "none";
						}
	
						 if(!usr_profile_cache.currentProperties.postPayments){
							 $("payment_create_li").style.display = "none";
						}						
					
				} 
			}catch(ex){}
		}
	}

}

setup_userProfileCache(success_getLoggedInUserProfile);
</script>





<title>YSN</title>
</head>

<body class="yui-skin-sam" onload="man_height();u_show_userMainDiv();" >
	<header class="site_head">
    	<h1><a href="#" title="Go to Home">YSN</a></h1>
        <ul>
        	<li>Welcome <span><%=(userProfile.getLastName() + ", " + userProfile.getFirstName()) + " (" + (String)request.getSession().getAttribute("loggedInUser") + ")"%></span></li>
        	<li>
        		<article>
        		<div id="createDiv" class="group">
        			<div class="btnDiv">
						<input type="submit" name="" id="" value="Back"  onclick="javascript:u_show_backScreen();" />
						<input type="submit" name="" id="" value="Home"  onclick="javascript:u_show_userMainDiv();"/>
						<input type="submit" name="" id="" value="Logout" onclick="javascript:dologout()"/>
					</div>
       			 </div>
       			</article>
        	
        	</li>
            
        </ul>
        
      
    </header>
     <section id="site_section" class="group">
    	<div id="tn_user_main_div">
    		<%@ include file="/tnMain.jsp"%>
			
		</div>
 	</section>
 	<form action="/login" method="post" style="display:none;" id="logout_form" >
 		<div>
		<input type="hidden" id="lgoutaction" name="action" value="logout"/>
		<input type="hidden" id="lgoutUser" name="lgoutUser" id="lgoutUser" value=""/>
		</div>	
	</form>
</body>
</html>



